package com.zhuiYun.project.api.hotSellingList.hotDaoMapper;

import com.zhuiYun.project.api.commoditydetail.entity.Commodity;
import com.zhuiYun.project.api.hotSellingList.entity.CommodityType;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author syc
 * @date 2023/4/6 9:22
 */
@Mapper
public interface HotDaoMapper {
    /**
    * @Author sgo
    * @Description 热销榜根据类型排序
    * @Date 2023/4/7 14:37
    * @Return java.util.List<com.zhuiYun.project.api.commoditydetail.entity.Commodity>
    * @param typeId
    */
    @Select("select c.* FROM commodity_type ct left join " +
            "commodity_small_type  cst on " +
            "ct.id=cst.type_id " +
            "right JOIN " +
            "commodity c " +
            "on c.type_id=cst.id " +
            "where ct.id= #{typeId} " +
            "order by c.product_purchase_quantity Desc ")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = " ",column = "commodity_name"),
            @Result(property = "price",column = "price"),
            @Result(property = "productPurchaseQuantity",column = "product_purchase_quantity"),
            @Result(property = "favorablePrice",column = "favorable_price"),
            @Result(property = "goodsQuantity",column = "goods_quantity"),
            @Result(property = "vipPrice",column = "vip_price"),
            @Result(property = "point",column = "point"),
            @Result(property = "imageId",column = "image_id"),
            @Result(property = "imageViewId",column = "image_view_id"),
            @Result(property = "tag",column = "tag"),
            @Result(property = "back",column = "back"),
            @Result(property = "typeId",column = "type_id"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "update_time"),
            @Result(property = "delFlag",column = "del_flag"),
            @Result(property = "numberOfViews",column = "number_of_views"),
    })
    List<Commodity> QueryByCommodityBylist(@Param("typeId")Integer typeId);
    /**
    * @Author sgo
    * @Description  热销榜类型查询排序
    * @Date 2023/4/7 14:37
    * @Return java.util.List<com.zhuiYun.project.api.hotSellingList.entity.CommodityType>
    */
    @Select("select * from commodity_type order by number_of_views desc")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "typeName",column = "type_name"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "update_time"),
            @Result(property = "delFlag",column = "del_flag"),
            @Result(property = "imageId",column = "image_id"),
            @Result(property = "numberOfViews",column = "number_of_views")
    })
    List<CommodityType> HotCommodityTypeBy3();
}
